/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ssm.changeunit.command;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author 시리우스
 */
public class CommandWorkerOptions {
    private List<CommandWorkerOption> commandWorkerOptions;
    
    /**
     * 생성자
     */
    public CommandWorkerOptions() {
        commandWorkerOptions = new ArrayList<CommandWorkerOption>();
    }
    
    /**
     * 옵션이 있는지 검사합니다.
     * 
     * @param commandWorkerOptionName
     * @return
     */
    public boolean hasCommandWorkerOption(String commandWorkerOptionName) {
        // CommandWorkeres를 돌면서 찾습니다.
        for (CommandWorkerOption commandWorkerOption : commandWorkerOptions) {
            if(commandWorkerOption.getName().equals(commandWorkerOptionName)) 
                return true;
        }
        
        return false;
    }
    
    /**
     * CommandWorkerOption을 찾습니다.
     * 
     * @param commandWorkerOptionName
     * @return
     */
    public CommandWorkerOption getCommandWorkerOption(String commandWorkerOptionName) {
        // CommandWorkeres를 돌면서 찾습니다.
        for (CommandWorkerOption commandWorkerOption : commandWorkerOptions) {
            if(commandWorkerOption.getName().equals(commandWorkerOptionName)) 
                return commandWorkerOption;
        }
        
        return null;
    }
    
    /**
     * CommandWorkerOption을 추가합니다.
     * 
     * @param commandWorkerOption
     */
    public void addCommandWorkerOption(CommandWorkerOption commandWorkerOption) {
        // 이미 존재하는 경우 추가하지 않습니다.
        if( hasCommandWorkerOption(commandWorkerOption.getName()) ) 
                return ;
        
        // CommandWorkerOptions에 추가합니다.
        commandWorkerOptions.add(commandWorkerOption);
    }
}
